package chenji.yourticket.datacenter;

import java.util.HashMap;

import org.bukkit.entity.Player;

import chenji.yourticket.configuration.ConfigException;

public class PlayerDataCenter {
	private HashMap<Player, PlayerData> cache = new HashMap<Player, PlayerData>();

	public PlayerData getPlayerData(Player p) {
		if (!(cache.containsKey(p))) {
			this.loadPlayer(p);
		}
		return this.cache.get(p);
	}

	public void loadPlayer(Player p) {
		try {
			PlayerData pd = new PlayerData(p.getName());
			this.cache.put(p, pd);
		} catch (ConfigException e) {
			e.printStackTrace();
		}
	}

}
